﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;

// For more information on enabling Web API for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860

namespace Sino.CapacityCloud.Web
{
    public class CredentialsResponse
    {
        public int total { get; set; }
        public IEnumerable<Credential> list { get; set; }
    }
    
    public class Credential
    {
        public int index { get; set; }
        public string id { get; set; }
        public string appKey { get; set; }
        public string appSecrect { get; set; }

    }
    public class credential
    {
        public string appKey { get; set; }
        public string appSecrect { get; set; }
    }
    public class credentialAddResponse
    {
        public string Error { get; set; }
        public credentialsAddResponse Response { get; set; }
    }
    public class credentialsAddResponse
    {

    }
    public class credentialDeleteResponse
    {
        public string Error { get; set; }
        public credentialsDeleteResponse Response { get; set; }

    }
    public class credentialsDeleteResponse { }
    public class CredentialsController : Controller
    {
        [HttpGet("credentials")]
        public IActionResult credentials(int startIndex = 0, int count = 10)
        {
            
            var response = new CredentialsResponse()
            {
                total = 10,
                list = new List<Credential>() { new Credential() { id = Guid.NewGuid().ToString(), appKey = "kj7swf8o7rls2", appSecrect = "wGIRXpOChWGG" } }
            };
            return Json(response, new Newtonsoft.Json.JsonSerializerSettings() { ContractResolver = new DefaultContractResolver() });

        }

        [HttpPost("credentials")]
        public IActionResult Addcredentials([FromBody] credential credentials)
        {
            if (credentials == null)
            {
                return BadRequest();
            }
            var response = new credentialAddResponse()
            {
                Error = null,
                Response = new credentialsAddResponse()
                {
                }
            };
            return Json(response, new Newtonsoft.Json.JsonSerializerSettings() { ContractResolver = new DefaultContractResolver() });
        }

        [HttpDelete("credentials/{id}")]
        public IActionResult Deletecredential(string id)
        {
            if (id == null)
            {
                return BadRequest();
            }
            var response = new credentialDeleteResponse()
            {
                Error = null,
                Response = new credentialsDeleteResponse()
                {
                }
            };
            return Json(response, new Newtonsoft.Json.JsonSerializerSettings() { ContractResolver = new DefaultContractResolver() });
        }

    }
}
